feat(paths): use XDG base directories instead of ~/.plannotator#568
feat(paths): use XDG base directories instead of ~/.plannotator#568cwrau wants to merge 1 commit into
Conversation
New installations now store data, state, and config under the XDG Base Directory Specification: data -> $XDG_DATA_HOME/plannotator (plans, version history) state -> $XDG_STATE_HOME/plannotator (drafts, sessions, debug logs) config -> $XDG_CONFIG_HOME/plannotator (config.json, hooks) Existing installations are unaffected: the legacy ~/.plannotator directory is detected at runtime and used as-is for all three bases, so no migration is required for current users. The central logic lives in packages/shared/paths.ts, which exports getDataBase(), getStateBase(), and getConfigBase(). All six call sites (storage, draft, config, improvement-hooks, sessions, codex-review) now import from there instead of hardcoding homedir(). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
|
I understand this on one hand. And the code organization is great. On the other, this is a fairly big lift I need to just map out mentally. Also, there is a lot of convenience in ~/ dot directories. |
|
I had not seen this, and ended up submitting a PR for the same goal ( #612 ). Feel free to close mine. This must be a better implementation. But I do wanna say this is a very important upgrade in my opinion. If every program uses ~/.program_name then hour $HOME dirs get pretty full. It also usually requires manual intervention to remove what was installed, and makes it harder to track configs in a single repo. |
|
I will evaluate both approaches this weekend |
|
Hey, thanks for the PR. We went with a single |
Summary
packages/shared/paths.tswith three helpers:getDataBase(),getStateBase(),getConfigBase()plans/,history/) under$XDG_DATA_HOME/plannotator(default:~/.local/share/plannotator)drafts/,sessions/, debug logs) under$XDG_STATE_HOME/plannotator(default:~/.local/state/plannotator)config.json, improvement hooks) under$XDG_CONFIG_HOME/plannotator(default:~/.config/plannotator)~/.plannotatoralready exists on disk, all three helpers return it — zero migration requiredCall sites updated
packages/shared/storage.tsgetDataBase()for plans + historypackages/shared/draft.tsgetStateBase()for draftspackages/shared/config.tsgetConfigBase()for config.jsonpackages/shared/improvement-hooks.tsgetConfigBase()for hooks dirpackages/server/sessions.tsgetStateBase()for sessionspackages/server/codex-review.tsgetStateBase()for schema file + debug logMigration for existing users
No action needed —
~/.plannotatorcontinues to work unchanged. To adopt XDG paths, simply move the directory:Config and state can be split further if desired:
Test plan
~/.local/share/plannotator/, state in~/.local/state/plannotator/, config in~/.config/plannotator/~/.plannotatorpresent: verify all paths still resolve to~/.plannotator(no regression)XDG_DATA_HOME,XDG_STATE_HOME,XDG_CONFIG_HOME: verify respected on fresh install🤖 Generated with Claude Code